package top.hidoctor.auscultation.adapter;

import android.bluetooth.BluetoothDevice;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tang.base.BaseResponse;

import java.util.List;

import top.hidoctor.auscultation.R;
import top.hidoctor.auscultation.bean.MyBluetoothDevice;

public class DevicesAdapter extends BaseQuickAdapter<MyBluetoothDevice> {

    public DevicesAdapter(int layoutResId, List<MyBluetoothDevice> data) {
        super(layoutResId, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, MyBluetoothDevice item) {
        helper.setText(R.id.tv_name, item.getBluetoothDevice().getName());
        helper.setText(R.id.tv_mac, item.getBluetoothDevice().getAddress());
        Button btn_connect = helper.getView(R.id.btn_connect);
        LinearLayout layout_connected = helper.getView(R.id.layout_connected);
        if (item.isConnect()) {
            btn_connect.setVisibility(View.GONE);
            layout_connected.setVisibility(View.VISIBLE);
        } else {
            btn_connect.setVisibility(View.VISIBLE);
            layout_connected.setVisibility(View.GONE);
        }
        helper.setOnClickListener(R.id.btn_connect, new OnItemChildClickListener());
        helper.setOnClickListener(R.id.btn_disconnect, new OnItemChildClickListener());
        helper.setOnClickListener(R.id.btn_detail, new OnItemChildClickListener());
        helper.setOnClickListener(R.id.btn_lvyin, new OnItemChildClickListener());
        helper.setOnClickListener(R.id.btn_stop, new OnItemChildClickListener());

    }


}
